﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using LIM.forms.uc_SYS_PhanQuyenHeThong;

using LIM.controller;
using LIM.model;
using Telerik.WinControls.UI;
using System.Threading;

namespace LIM.forms
{
    public partial class radForm_SYS_PhanQuyenHeThong : Telerik.WinControls.UI.RadForm
    {
        public SYSController _SYSController = new SYSController();

        public delegate void ListControlOnIndexChanged();
        public event ListControlOnIndexChanged OnIndexChanged;

        public tbl_SYS_Roles SelectedEntity { set; get; }

        uc_SYS_PhanQuyenHeThong_Menu uc_SYS_PhanQuyenHeThong_Menu;
        uc_SYS_PhanQuyenHeThong_Form uc_SYS_PhanQuyenHeThong_Form;
        
        public radForm_SYS_PhanQuyenHeThong()
        {
            InitializeComponent();

            uc_SYS_PhanQuyenHeThong_Menu = new uc_SYS_PhanQuyenHeThong_Menu();
            uc_SYS_PhanQuyenHeThong_Menu.Dock = DockStyle.Fill;
            this.radPageViewPage_Menu.Controls.Add(uc_SYS_PhanQuyenHeThong_Menu);

            uc_SYS_PhanQuyenHeThong_Form = new uc_SYS_PhanQuyenHeThong_Form();
            uc_SYS_PhanQuyenHeThong_Form.Dock = DockStyle.Fill;
            this.radPageViewPage_Form.Controls.Add(uc_SYS_PhanQuyenHeThong_Form);
        }

        private void radForm_SYS_PhanQuyenHeThong_Load(object sender, EventArgs e)
        {
            radListControl_NhomQuyenHeThong.DataSource = _SYSController.GetList_Roles();            
        }

        private void radListControl_NhomQuyenHeThong_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
        {
            SelectedEntity = (tbl_SYS_Roles)this.radListControl_NhomQuyenHeThong.SelectedItem.DataBoundItem;
            if (OnIndexChanged != null)
                OnIndexChanged();
        }
        
        public void RefreshData()
        {
            _SYSController.Refresh_tbl_DanhMuc_ThongTinNhanVien();
            radForm_SYS_PhanQuyenHeThong_Load(new object(), new EventArgs()); 
        }

    }
}
